package lib.wzh.com.libcore.cloud.mybatis;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @Author lib
 * @Date 2021/11/30 16:30
 * @ClassName MyMetaObjectHandler
 * @Version v1.0
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject,"tenantId",String.class,"lib_cr_admin");
        this.strictInsertFill(metaObject,"createBy",String.class,"lib_cr_admin");
        this.strictInsertFill(metaObject, "createDate", LocalDateTime::now, LocalDateTime.class);
        this.strictInsertFill(metaObject, "updateDate", LocalDateTime::now, LocalDateTime.class);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject,"updateBy",String.class,"lib_up_admin");
        this.strictUpdateFill(metaObject, "updateDate", LocalDateTime::now, LocalDateTime.class);
    }

}
